www.gusucode.com > VC++ 代码实现绘制生成一个五角星-源码程序 > VC++ 代码实现绘制生成一个五角星-源码程序/code/SetDlg.cpp
//Download by http://www.NewXing.com // SetDlg.cpp : implementation file // #include "stdafx.h" #include "Five.h" #include "SetDlg.h" #include "Pentacle.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSetDlg dialog CSetDlg::CSetDlg(CPentacle* pPen, CWnd* pParent /*=NULL*/) : CDialog(CSetDlg::IDD, pParent) { //{{AFX_DATA_INIT(CSetDlg) m_iWidth = 0; m_iHigh = 0; m_iNumber = 0; //}}AFX_DATA_INIT m_pPentacle = pPen; m_color = RGB(255, 0, 0); } void CSetDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSetDlg) DDX_Text(pDX, IDC_EDIT_WIDTH, m_iWidth); DDX_Text(pDX, IDC_EDIT_HIGH, m_iHigh); DDX_Text(pDX, IDC_NUMBER, m_iNumber); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSetDlg, CDialog) //{{AFX_MSG_MAP(CSetDlg) ON_BN_CLICKED(IDC_UPDATE, OnUpdate) ON_BN_CLICKED(IDC_COLOR, OnColor) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSetDlg message handlers // 更新函数 void CSetDlg::OnUpdate() { // TODO: Add your control notification handler code here UpdateData(TRUE); m_pPentacle->SetColor(m_color); if ( 1 == ((CButton*)GetDlgItem(IDC_FIVE))->GetCheck() ) { m_pPentacle->CalculateFivePoint(m_iWidth, m_iHigh); } else { m_pPentacle->CalculatePoint(m_iWidth, m_iHigh, m_iNumber); } GetParent()->Invalidate(); } void CSetDlg::OnColor() { // TODO: Add your control notification handler code here CColorDialog dlg; dlg.DoModal(); m_color = dlg.GetColor(); } BOOL CSetDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_iWidth = m_pPentacle->GetWidth(); m_iHigh = m_pPentacle->GetHigh(); m_iNumber = m_pPentacle->GetPointNumber(); ((CButton*)GetDlgItem(IDC_FIVE))->SetCheck(1); UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }